<% title "#{@repository} tree" %>

<%=partial :repo_header %>

<div id="tree">
  <% @resource.contents.sort { |a, b| [b.class.name, a.name.downcase] <=> [a.class.name, b.name.downcase] }.each do |f| %>
    <% if f.is_a?(Grit::Tree) %>
      <div class="tree gradient">
        <div class="name"><%= link_to "#{f.name}/", tree_for_commit_path(@repository, params[:commit], @splat, f.name) %></div>
      </div>
    <% else %>
      <div class="blob gradient">
        <div class="name"><%= link_to f.name, blob_for_commit_path(@repository, params[:commit], @splat, f.name) %></div>
      </div>
    <% end %>
  <% end %>
</div>

<% if @readme %>
  <div id="readme">
    <div class="section_bar gradient">
      <%=link_to @readme.name, raw_blob_for_commit_path(@repository, params[:commit], @splat, @readme.name) %>
    </div>
    <div id="guide">
      <%=@readme_contents %>
    </div>
  </div>
<% end%>
